#include<bits/stdc++.h>
using namespace std;
int n;
string a,b;
string ans;
int maxn=0;
int sum;
int main(){
	cin>>n;
	int i,j;
	for(i=1;i<=n;i++){
		cin>>a>>b;
		j=0;
		sum=0;
		while(b[3]!='\0'&&b[j+2]!='\0') {
			if(b[j]=='s'&&b[j+1]=='o'&&b[j+2]=='s') {
				sum++;
				j+=2; 
			}
			else j++;
		};
		if(sum>maxn){
			maxn=sum;
			ans=a;
		}
		else if(maxn==sum){
			ans=ans+" "+a;
		}
	};
	cout<<ans<<endl;
	cout<<maxn;
	return 0;
}
